package com.inventory.api.entity;

import com.inventory.api.signUpReq.StockCheckSignUpReq;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import java.util.Date;

/**
 * Created by lihu on 2018/2/2.
 */
@Entity
@Data
@NoArgsConstructor
public class StockCheckOrder {


    @Id
    @Column(length = 50)
    private String id;

    @Column(length = 50)
    private String storeId;

    /**
     * 操作人id
     */
    private String operatorId;

    /**
     * 操作人名称
     */
    private String operatorName;

    /**
     * 种类
     */
    private int kind;

    /**
     * 盘盈总个数量
     */
    private int singleProfit;

    /**
     * 盘盈总件数量
     */
    private int wholeProfit;

    /**
     * 盘亏总个数量
     */
    private int singleLosses;


    /**
     * 盘亏总件数量
     */
    private int wholeLosses;

    /**
     * 备注
     */
    private String notes;

    /**
     * 操作时间
     */
    @Column(columnDefinition = "TIMESTAMP(3) NULL")
    private Date operTime;
    @Column(insertable = false, updatable = false, columnDefinition = "TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP(3)")
    private Date addTime;

    /**
     * 初始化数据
     *
     * @param signUpReq
     */
    public StockCheckOrder(StockCheckSignUpReq signUpReq) {
        id = signUpReq.getId();
        storeId = signUpReq.getStoreId();
        operatorId = signUpReq.getOperatorId();
        operatorName = signUpReq.getOperatorName();
        kind = signUpReq.getKind();
        singleProfit = signUpReq.getSingleProfit();
        wholeProfit = signUpReq.getWholeProfit();
        singleLosses = signUpReq.getSingleLosses();
        wholeLosses = signUpReq.getWholeLosses();
        operTime = new Date();
        notes = signUpReq.getNotes();
    }
}
